package com.resign.carl.composite.api.impl;

import com.resign.carl.composite.api.MenuComponent;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.util.Iterator;

/**
 *
 * 菜单项：实现组合内元素的行为
 * Created by carl.zhao on 2016/6/16.
 */
@AllArgsConstructor
@Getter
@Setter
public class MenuItem extends MenuComponent {

    private String name;
    private String description;
    private boolean vegetarian;
    private double price;

    public void print(){
        System.out.print(" " + getName());
        if(isVegetarian()){
            System.out.print("(v)");
        }
        System.out.println(", " + getPrice());
        System.out.println("    -- " + getDescription());
    }

    public Iterator createIterator(){
        return new NullIterator();
    }
}
